#pragma once

namespace GB
{
	// Coordinate Infos
	const int BoardWidth = 537;
	const int BoardHeight = 537;

	const int BoardLeft = 21;
	const int BoardTop = 21;

	const int GridLineMargin = 35;
	const int GridRowMargin = 35;
	const int ChessMargin = 33;

	const int LineMargins[] = { 21, 56, 91, 126, 162, 197, 232, 268, 
	                            304, 339, 374, 410, 445, 480, 515 };

	// Chess board Infos
	const int MaxRow = 15;
	const int MaxLine = 15;

	// Calculate row and line 
	inline void CalcPosition(int xCoord, int yCoord, int &row, int &line)
	{
		int rowInt = (yCoord - BoardTop) / GridRowMargin;
		float rowFlt = (yCoord - BoardTop) / (float)GridRowMargin;

		if (rowFlt - rowInt < 0.5)
		{
			row = rowInt;
		}
		else
		{
			row = rowInt + 1;
		}

		int lineInt = (xCoord - BoardLeft) / GridLineMargin;
		float lineFlt = (xCoord - BoardLeft) / (float)GridLineMargin;

		if (lineFlt - lineInt < 0.5)
		{
			line = lineInt;
		}
		else
		{
			line = lineInt + 1;
		}

	}

	// enum chess types
	enum CHESS_TYPE
	{
		CHESS_NONE,
		CHESS_BLACK,
		CHESS_WHITE,
	};

    inline CHESS_TYPE EnemyType(CHESS_TYPE type)
    {
        switch (type)
        {
        case CHESS_NONE:
            return CHESS_NONE;
        case CHESS_BLACK:
            return CHESS_WHITE;
        case CHESS_WHITE:
            return CHESS_BLACK;
        }
    }

	// enum game results
	enum GAME_RESULT
	{
		NO_WIN,
		BLACK_WIN,
		WHITE_WIN,
		DRAW
	};

    // enum game modes
    enum GAME_MODE
    {
        MOD_2P,
        MOD_AI_BLACK,
        MOD_AI_WHITE
    };

	// Sequence to win
	const int WinNum = 5;
}
